package org.jmh.gift.strategy;

import cn.hutool.core.util.StrUtil;

public class PlaceOrderSplitOrderStrategyFactory {

    public static IPlaceOrderSplitOrderStrategy getStrategy(String className){
        if(StrUtil.isBlank(className)){
            throw new RuntimeException("splitOrder strategy是空");
        }
        try {
            Class<?> aClass = Class.forName(className);
            Object o = aClass.newInstance();
            if(o instanceof  IPlaceOrderSplitOrderStrategy){
                return (IPlaceOrderSplitOrderStrategy)o;
            }
            throw new RuntimeException("this strategy不被支持");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
}
